<?php
// includes
include_once 'functions.php';
include_once 'includes.php';
includes::loadAll();

// debug request?
if ($_GET["debug"] == 1 && $_SERVER["HTTP_HOST"] == "localhost") {
    config::getInstance()->debug = true;
}

// strict messages in debug mode
if (config::getInstance()->debug) {
    if ($_SERVER["HTTP_HOST"] == "localhost") {
		include_once 'firelogger.php';
	} else {
		function flog($log = null, $var = null) {}
	}
	error_reporting(E_ALL | E_STRICT);
	// error handling
	set_error_handler(array('error', 'handler'));
} else {
	function flog($log = null, $var = null) {}
	error_reporting(E_NONE);	
}

// start session
session_start();

// request
$request = new request($_GET);

// begin document
$doc = document::createInstance($request);

// prefs
prefs::createInstance();

// preload
preloader::getInstance()->run();

// main contents
ob_start();
module::load($request);	
$doc->contents["main"] = ob_get_contents();
ob_end_clean();

// echo document
$doc->output("header");
$doc->output("body");
$doc->output("footer");
	
?>